<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.ParseException"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%@page import="com.tjsinfo.tjsoa.schedule.vo.ScheduleMain"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String nowtime = (String) request.getAttribute("nowtime");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<style>
.lan01 {
	background: url(<%=basePath%>images/lanbg01.gif) no-repeat 0 0;
	width: 6px;
	height: 24px;
}

.lan02 {
	background: url(<%=basePath%>images/lanbg02.gif) repeat-x;
	width: 99%;
	height: 24px;
}

.lan03 {
	background: url(<%=basePath%>images/lanbg03.gif) no-repeat;
	width: 8px;
	height: 24px;
}

.cha {
	padding-top: 3px
}
</style>
		<base href="<%=basePath%>" />
		<title>粮油集团办公自动化协作平台</title>
		<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" />
		<script language="javascript" type="text/javascript" src="<%=basePath%>My97DatePicker/WdatePicker.js"></script>
		<script type='text/javascript' src='<%=basePath%>dwr/interface/ScheduleMainBo.js'></script>
		<script type='text/javascript' src='<%=basePath%>dwr/engine.js'></script>
		<script type='text/javascript' src='<%=basePath%>dwr/util.js'></script>
		<link href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/ext-all.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
		<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/common/global/validator.js"></script>
		<style type="text/css">
td {
	font: 12px/ 170% "宋体", "新宋体", "黑体";
	color: #000
}

th {
	font: 12px/ 170% "宋体", "新宋体", "黑体";
	color: #000
}

.trBgColor {
	background-color: #A4D7E8;
	cursor: hand;
}
</style>
		<script type="text/javascript">
		function deletefrom(userid){
			 Ext.MessageBox.confirm("OA办公自动化系统","您确定要删除该条记录?",function(btn){
			 	if(btn == 'yes'){
			 		 ScheduleMainBo.DeleteById(document.getElementById('content').value,document.getElementById('year').value,document.getElementById('month').value,document.getElementById('day').value,document.getElementById('startHour').value,userid);
					 document.getElementById('newSchedule').style.display='none';
					 document.getElementById('tr'+document.form1.startHour.value).innerHTML='';
					 document.getElementById('content').innerTEXT='';
					 document.getElementById('yuan'+document.form1.startHour.value).value='';
			 	}
			 });
 		}
		function newfrom(a,showDate,aa,day,trid)
	    {		
	      document.getElementById('content').value='';
	       document.form1.startHour.value = a;
	       document.getElementById('trid').value=trid;
	       document.getElementById('table').rows[0].cells[1].innerHTML="<%=nowtime%>&nbsp;&nbsp;&nbsp;"+showDate+"&nbsp;&nbsp;"+day+""+aa+"点";
	       document.getElementById('content').value=document.getElementById('yuan'+a).value;
		   document.getElementById('newSchedule').style.top =  document.body.clientHeight/5;
		   document.getElementById('newSchedule').style.left = document.body.clientWidth/5;
		   document.getElementById('newSchedule').style.display = "block";
	    }
		function newSchedule(userid)
	    {
	
	    	if(isstringnull($("#content").text(),"内容不能为空"))
	    	{
	    		
	    		if($("#content").text().length<400)
	    		{
	    			document.getElementById('yuan'+document.form1.startHour.value).value=document.getElementById('content').value;
				     if(document.form1.content.value.length>=40){
				     	document.getElementById('tr'+document.form1.startHour.value).innerHTML=document.getElementById('content').value.substring(0,40);
				     }else
				     {
				     	document.getElementById('tr'+document.form1.startHour.value).innerHTML=document.getElementById('content').value;
				     }
				     if(document.getElementById('startHour').value<7){
				     	document.getElementById('startHour').value = parseInt(document.getElementById('startHour').value)+24;
				     		
				     }
						ScheduleMainBo.save(document.getElementById('content').value,document.getElementById('year').value,document.getElementById('month').value,document.getElementById('day').value,document.getElementById('startHour').value,userid);
						document.getElementById('newSchedule').style.display='none';
						document.getElementById('content').value='';	
						window.location.reload(); 
			    }
			    else
		    	{
		    			Ext.MessageBox.alert('提示信息', '内容长度不能超过400');
		    	}			
	    	}	    				     		
	    }
	   
	    function qxdeletefrom()
		{
			document.getElementById('newSchedule').style.display = "none";
		}
		</script>
	</head>

	<body>
		<%
			int a = 7, b = 8;
			Date date = null;
			User user = (User) session.getAttribute("user");
			List list = (List) request.getAttribute("list");
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

			try {
				date = dateFormat.parse(nowtime);
			} catch (ParseException e) {

			}
			
			Calendar cd = Calendar.getInstance();
			cd.setTime(date);
			int mydate = cd.get(Calendar.DAY_OF_WEEK);
			String showDate = "";
			switch (mydate) {
			case 1:
				showDate = "星期日";
				break;
			case 2:
				showDate = "星期一";
				break;
			case 3:
				showDate = "星期二";
				break;
			case 4:
				showDate = "星期三";
				break;
			case 5:
				showDate = "星期四";
				break;
			case 6:
				showDate = "星期五";
				break;
			default:
				showDate = "星期六";
				break;
			}
		%>
		<div style="height: 97%;">
			<div id="rightindex">
				<div id="tabtj">
					<!--导航开始处-->
					<div id="indextit">
						日程安排
					</div>
					<div id="index_main">
					</div>
					<div id="workduty">
						<ul>
							<li class="s01">
								<a href="<%=basePath%>tjsinfo/tjsoa/schedule/schedule.do"><span>日安排</span>
								</a>
							</li>
							<li class="s01">
								<a
									href='<%=basePath%>/tjsinfo/tjsoa/schedule/scheduleWeeks.do?time=<%=nowtime%>'><span>周安排</span>
								</a>
							</li>
							
						</ul>
					</div>

					<div class="contab01" style="height: 89.5%" id="div3">
						<table class="p_06" width="100%" border="0" cellspacing="0">
							<tr>
								<td colspan="2" align="center" style="background-color: #C3D9FF">
									<%
										Date date2 = new Date();
										SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
										String jint = "";
										if (nowtime.equals(format.format(date2))) {
											jint = "(今天)";
									%>
									<%
									}
									%>
									<font color=112ABB><%=nowtime%>&nbsp;<%=jint%>&nbsp;&nbsp;<%=showDate%></font>
								</td>
							</tr>
							<tr>
								<td width="85%">
									<div id="div2"
										style="height: 460px; overflow-x: hidden; overflow-y: scroll;">
										<table width="100%" id="dd" bordercolor="#DDDDDD">
											<%
												int d = 0;
												for (int i = 7; i <= 30; i++) {
											%>
											<tr>
												<%
														String day = "上午";
														int aa = a;
														if (a > 12) {
															day = "下午";
															aa = a - 12;
														}
														if (a > 24) {
															day = "上午";
															aa = a - 24;
														}
												%>
												<td width="20%" align="center"
													style="background-color: #E8EEF7">
													<font color=446688><%=day%><%=aa%>点</font>
												</td>
												<td width="80%">
													<%
													if (list == null || d >= list.size()) {
													%>
													<div id="tr<%=a%>"
														onclick="newfrom(<%=a%>,'<%=showDate%>',<%=aa%>,'<%=day%>','tr<%=a%>')"
														style="width: 100%">
														&nbsp;
													</div>
													<input type="hidden" id="yuan<%=a%>" />
													<%
																} else {

																ScheduleMain main = (ScheduleMain) list.get(d);
																if (i == Integer.valueOf(main.getScheduleHour())) {
															d++;
															String conn = main.getContent();
															String s1 = "<br/>";
															String s2 = conn.replaceAll(s1, "&nbsp;");
															main.setContent(s2);
															conn=s2;
															if (main.getContent().length() >= 40) {
																conn = main.getContent().substring(0, 40);

															}
													%>
													<div id="tr<%=a%>" style="background-color: #FFFFCC"
														onclick="newfrom(<%=a%>,'<%=showDate%>',<%=aa%>,'<%=day%>','tr<%=a%>')">
														<a title="<%=main.getContent()%>"><%=conn%></a>
													</div>
													<input type="hidden" id="yuan<%=a%>"
														value="<%=main.getContent()%>" />
													<%
													} else {
													%>
													<div id="tr<%=a%>"
														onclick="newfrom(<%=a%>,'<%=showDate%>',<%=aa%>,'<%=day%>')"
														style="width: 100%">
														&nbsp;
													</div>
													<input type="hidden" id="yuan<%=a%>" />
													<%
															}
															}
													%>
													<%
													a++;
													%>
												</td>
											</tr>
											<%
											}
											%>
										</table>
									</div>
								</td>
								<td width="15%" valign="top">
									<table>
										<tr>
											<td align="right">
												<div id="div1"></div>
											</td>
										<tr>
									</table>
								</td>
							</tr>
						</table>
					</div>
				</div>
			</div>
		</div>

		<form name="form1" method="post" id="form1">
			<div
				style="display: none; text-align: center; position: absolute; left: 0px; top: 0px; background-color: black;"
				id="newSchedule">
				<table width="478" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td>
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td class="lan01">
										&nbsp;
									</td>
									<td class="lan02">
										<table width="99%" border="0" cellspacing="0" cellpadding="0"
											id="table">
											<tr>
												<td width="5%" align="center" style="padding-top: 3px;">

												</td>
												<td width="89%" align="left"
													style="color: #FFFFFF; font-weight: bold; padding-top: 3px;">

												</td>
												<td width="6%">
													<div class="cha">
														<a href="javascript:qxdeletefrom()"><img
																src="<%=basePath%>images/cha.gif" /> </a>
													</div>
												</td>
											</tr>
										</table>
									</td>
									<td class="lan03">
										&nbsp;
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td height="109" class="zz">
							<table width="400" border="0" cellspacing="0" cellpadding="0"
								class="researchtab">
								<tr>
									<td width="15%" align="center">
										<img src="<%=basePath%>images/bjicon.jpg" />
									</td>
									<td width="83%" align="left">
										<textarea rows="15" cols="50" name="content" id="content"></textarea>
									</td>
								</tr>
								<tr>
									<td align="center" colspan="2"
										style="border-top: 1px #CFCFD1 solid">

										<a href="javascript:newSchedule('<%=user.getUser_id()%>')"
											style="display: inline"><img style="display: inline"
												src="<%=basePath%>images/qd.gif" /> </a>

										<a href="javascript:deletefrom('<%=user.getUser_id()%>')"
											style="display: inline"><img style="display: inline"
												src="<%=basePath%>images/shanchu.gif" /> </a>

										<a href="javascript:qxdeletefrom()" style="display: inline"><img
												style="display: inline" src="<%=basePath%>images/qx.gif" />
										</a>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
			<input type="hidden" name="startHour" value="" />
			<input type="hidden" name="trid" value="" />
			<input type="hidden" name="year" value="<%=nowtime.split("-")[0]%>" />
			<input type="hidden" name="month" value="<%=nowtime.split("-")[1]%>" />
			<input type="hidden" name="day" value="<%=nowtime.split("-")[2]%>" />
		</form>
		<script>
			var ieheight=document.getElementById("div3").offsetHeight;
			document.getElementById("div2").style.height=ieheight-40;
			document.getElementById("div3").style.height=ieheight-10;
			WdatePicker({eCont:'div1',startDate:'<%=nowtime%>',onpicked:function(dp){window.location.href='<%=basePath%>tjsinfo/tjsoa/schedule/scheduleDay.do?time='+dp.cal.getDateStr()+'';}});
		</script>
	</body>
</html>
